<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link href="../../assets/css/maincss.css" rel="stylesheet" />
<link href="../../assets/css/but.css" rel="stylesheet" />
</head>
<body>
<h3>供应商管理</h3>
<a href="searchProviders.jsp">查询供应商</a>
<table border="1px" cellspacing="0" height="280px" width="1100px" align="center" style="text-align: center;" rules="rows" frame="void">
	<tr>
		<td colspan="9" style="text-align: right;">
			<button onclick="addProviderBut()" class="but green">增 加</button>
		</td>
	</tr>
	<tr>
		<td>供应商id</td>
		<td>供应商名称</td>
		<td>供应商地址</td>
		<td>供应商电话</td>
		<td>账户</td>
		<td>邮箱</td>
		<td>操作</td>
	</tr>
	<c:forEach items="${page.list}" var="provid">
		<tr>
			<td>${provid.providerId}</td>
			<td>${provid.providerName}</td>
			<td>${provid.providerAdd}</td>
			<td>${provid.providerTel}</td>
			<td>${provid.account}</td>
			<td>${provid.email}</td>
			<td>
				<button onclick="editProviderById(${provid.providerId})" class="but green">修 改</button>
				&nbsp;
				<button onclick="return delProviderById(${provid.providerId})" class="but red">删 除</button>
			</td>
		</tr>
	</c:forEach>
	
	<tr align="center">
		<td colspan="9">
			
			<c:if test="${page.currentPage != 1}">
				<a href="ProviderServlet?op=showProvidersByPage&currentPage=${page.upPage()}">[上一页]</a>
			</c:if>
			
			&nbsp;&nbsp;&nbsp;&nbsp;
			当前第${page.currentPage}页
			&nbsp;&nbsp;
			共${page.total}条数据
			&nbsp;&nbsp;
			共${page.totalPages()}页
			&nbsp;&nbsp;&nbsp;&nbsp;
			<c:if test="${page.currentPage != page.totalPages()}">
				<a href="ProviderServlet?op=showProvidersByPage&currentPage=${page.nextPage()}">[下一页]</a>
			</c:if>
		</td>
	</tr>
</table>

</body>
<script type="text/javascript">
	
	// 修改
	function editProviderById(id){
		location.href = 'ProviderServlet?op=readyEditProviderById&id='+id;
	}
	
	// 删除
	function delProviderById(id){
		var msg = "确定删除该条数据?";
		if(confirm(msg) == true){
			location.href='ProviderServlet?op=removeProviderById&id='+id;
			return true;
		} else {
			return false;	
		}
	}
	
	// 增加
	function addProviderBut(){
		location.href='addProvider.jsp';
	}



</script>

</html>